// 飞机类
function Plane(width,height,url,x,y){

    this.width = width;
    this.height = height;
    this.x = x;
    this.y = y;

    var img = new Image()
    img.src = url
    img.style.position = 'absolute'
    img.style.width = width + 'px'
    img.style.height = height + 'px'

    img.style.left = x + 'px'
    img.style.top = y + 'px'
    this.node = img;
    // append到父元素上
    document.querySelector(".wrapper").appendChild(img)
}

Plane.prototype.fly = function(x,y){
    if(x != null){
        this.x = x - this.width/2;
        this.node.style.left = this.x + 'px'
    }
    if(y != null){
        this.y = y;
        this.node.style.top = this.y + 'px'
    }
}

Plane.prototype.die = function(){
    if(this.node.parentNode){
        this.node.src = "./img/bombimg.png"
        var node = this.node;
        (function(node){
            setTimeout(function(){
                node.parentNode.removeChild(node)
            }.bind(this),200)
        })(node)
    }
}